<template>
	<div>
		<div class="w-tabtitle">申请发票</div>
		<el-form ref="form" :model="billsizeForm" label-width="120px">
			<el-form-item label="发票类型">
				<el-select placeholder="发票类型" v-model="values" class="w-ele">
					<el-option v-for="item in slots" :label="item.label" :value="item.value" :key="item.value"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="发票抬头">
				<el-radio-group v-model="billsizeForm.type">
					<el-radio label="1">企业单位</el-radio>
					<el-radio label="2">个人/非企业单位</el-radio>
				</el-radio-group>
			</el-form-item>
			<el-form-item label="税号">
				<el-input v-model="billsizeForm.taxId" placeholder="填写纳税人识别号"></el-input>
			</el-form-item>
			<el-form-item label="总金额">
				<el-input v-model="billsizeForm.donate" placeholder="填写发票总金额"></el-input>
			</el-form-item>
			<el-form-item label="电子邮件">
				<el-input v-model="billsizeForm.email" placeholder="用于向您发送电子发票" type="email"></el-input>
			</el-form-item>
			<el-form-item>
				<el-button @click="addInvoice">提交</el-button>
			</el-form-item>
		</el-form>
	</div>
</template>

<script>
	import {
		invoiceAdd
	} from '@/api/invoice'
	export default {
		name: 'incoiceForm',
		props:['id'],
		data() {
			return {
				billsizeForm: {},
				slots: [{
						value: '普票',
						label: '普票'
					},
					{
						value: '增值税发票',
						label: '增值税发票'
					},
				],
				values: ""
			}
		},
		mounted(){
			console.log(this.id)
		},
		methods: {
			
			// 添加发票
			addInvoice() {
				this.billsizeForm.invoiceType = this.values
				this.billsizeForm.donateId = this.id
				console.log(this.billsizeForm)
				invoiceAdd(this.billsizeForm).then(response => {
					Message({
						message: '添加成功',
						type: 'success',
						duration: 5 * 1000
					})
					this.$router.go(-1)
				})
			},
		}
	}
</script>

<style scoped>
	.w-tabtitle {
		margin-top: 39px;
		margin-bottom: 47px;
		font-size: 30px;
		color: rgba(51, 51, 51, 1);
		text-align: center;
		font-weight: 500;
	}
</style>
